<?php
	$cateID=$_POST['cateID'];
	$groupID = $_POST['groupID'];
	$productname=$_POST['productname'];
	
	$target="../user/upload/products/";
	$link=$target.$_FILES['productImage']['name'];
	move_uploaded_file($_FILES['productImage']['tmp_name'],$link);
	
	$productDetail = $_POST['productDetail'];
	
	$productPrice = $_POST['productPrice'];
	$productWarranty = $_POST['productWarranty'];
	if(!empty($_POST['productHot'])){
		$productHot = $_POST['productHot'];	
	}else{
		$productHot = 0;	
	}
	
	if(!empty($_POST['promotion'])){
		$promotion = $_POST['promotion'];
	}else{
		$promotion=0;
	}	
	
	$state = $_POST['state'];
	
	$query="INSERT INTO productdetails(cateID,groupID,productname,imgpath,productDetail,productPrice,productWarranty,productHot,promotion,state) VALUES ('$cateID','$groupID','$productname','$link','$productDetail','$productPrice','$productWarranty','$productHot',$promotion,'$state')";
	mysql_query($query);
	echo "Thêm sản phẩm thành công.";
	echo "<script>window.location='index.php?admin=productAdmin&do=listproduct'</script>";	
?>	